from django.db import models

# Create your models here.


class Student(models.Model):
    gender_choices = (('男', '男'), ('女', '女'))
    # 学号
    sno = models.IntegerField(db_column='SNo', primary_key=True, null=False)
    # 姓名
    name = models.CharField(db_column='SName', max_length=100, null=False)
    # 性别
    gender = models.CharField(db_column='Gender', max_length=100, choices=gender_choices)
    # 出生日期
    birthday = models.DateField(db_column='Birthday', auto_now=True, null=False)
    # 手机号码
    mobile = models.CharField(db_column='Mobile', max_length=100)
    # 邮箱地址
    email = models.CharField(db_column='Email', max_length=100)
    # 家庭住址
    address = models.CharField(db_column='Address', max_length=200)
    # 照片
    image = models.CharField(db_column='Image', max_length=200, null=True)

    # 在默认情况下  生成的表名App_class
    class Meta:
        managed = True
        db_table = 'Student'

    # __str__ 方法
    def __str__(self):
        return "学号:%s\t姓名:%s\t性别:%s" % (self.sno, self.name, self.gender)
